package main

import "fmt"

func main() {

	s1 := []string{"hello", "world"}
	s2 := append(s1, "sss")
	fmt.Println(s2)

	// 创建数组
	arr := [4]string{"nhooo", "gfg", "nhooos1231", "www.nhooo.com"}
	mySlice := arr[0:1]
	fmt.Println(mySlice)
	fmt.Println(len(mySlice))

	// 等于底层数组的长度
	fmt.Println(cap(mySlice))

	mySlice4 := []string{"苹果", "橘子", "香蕉", "西瓜", "大鸭梨"}
	fmt.Println(mySlice4)
	fmt.Println(len(mySlice4))
	fmt.Println(cap(mySlice4))

	mySlice5 := make([]string, 0)
	mySlice5 = append(mySlice5, "苹果")
	fmt.Println(mySlice5)
	fmt.Println(len(mySlice5))
	fmt.Println(cap(mySlice5))

	mySlice5 = append(mySlice5, "橘子")
	fmt.Println(mySlice5)
	fmt.Println(len(mySlice5))
	fmt.Println(cap(mySlice5))

	mySlice5 = append(mySlice5, "香蕉")
	fmt.Println(mySlice5)
	fmt.Println(len(mySlice5))
	fmt.Println(cap(mySlice5))

	mySlice5 = append(mySlice5, "西瓜")
	fmt.Println(mySlice5)
	fmt.Println(len(mySlice5))
	fmt.Println(cap(mySlice5))

	mySlice5 = append(mySlice5, "大鸭梨")
	fmt.Println(mySlice5)
	fmt.Println(len(mySlice5))
	fmt.Println(cap(mySlice5))

	for i := 0; i < len(mySlice5); i++ {
		fmt.Println(i, mySlice5[i])
	}

	for k, v := range mySlice5 {
		fmt.Println(k, v)
	}

	var slice8 = mySlice5[:]
	fmt.Println(slice8)
}
